<?php

use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\Hash;
use App\Department;
use App\Employee;
use App\User;



class DataSeeder extends Seeder
{
    /**
     * Run the database seeds.
     *
     * @return void
     */
    public function run()
    {
        $faker = Faker\Factory::create('zh_CN');

        collect(['学院办公室','教务处','信息技术系','建筑工程系'])->each(function($v,$k) use($faker){
            Department::create([
                'name' => $v,
                'address' => '',
                'telephone' => $faker->numerify("6#######"),
                'fax' => $faker->numerify("6#######"),
            ]);
        });

        for($i=0;$i<80;$i++){
            $gender = $faker->randomElement(['male','female']);
            $e = Employee::create([
                'name' => $faker->name($gender),
                'gender' => $gender=="male"? false:true,
                'birth_date' => $faker->dateTimeBetween('-59 years','-18 years'),
                'title' => $faker->randomElement(['教员','讲师','高级讲师','初级实习指导教师','中级实习指导教师','高级实习指导教师']),
                'position' => $faker->randomElement(['专职教师','专职教师','专职教师','专职教师','专职教师','管理人员','管理人员','工勤人员']),
                'mobile_phone' => $faker->numerify("189########"),
                'department_id' => $faker->randomElement([1,2,3,4])
            ]);

            User::create([
                'email' => $faker->email(),
                'password'=> Hash::make("secret"),
                'employee_id' => $e->id
            ]);
        }


    }
}
